function LoginAssistant() {
	/*
	 * this is the creator function for your scene assistant object. It will be
	 * passed all the additional parameters (after the scene name) that were
	 * passed to pushScene. The reference to the scene controller
	 * (this.controller) has not be established yet, so any initialization that
	 * needs the scene controller should be done in the setup function below.
	 */
}

LoginAssistant.prototype.btnOKModel = {
	label : "OK",
	buttonClass : "palm-button affirmative",
	disabled : false
};

LoginAssistant.prototype.btnCancelModel = {
	label : "Cancel",
	buttonClass : "palm-button dismiss",
	disabled : false
};

LoginAssistant.prototype.loginNameModel = {
	value : "test2@karavanov.com"
};
LoginAssistant.prototype.passwordModel = {
	value : "123456"
};

LoginAssistant.prototype.loginNameField = null;
LoginAssistant.prototype.passwordField = null;

LoginAssistant.prototype.setup = function() {

	// set callbacks
	authn.loginFailedBind = this.loginFailed.bind(this);
	authn.loginSucceededBind = this.loginSucceeded.bind(this);
	authn.loginFailedCaptchaBind = this.loginFailedCaptcha.bind(this);
	
	// login name field
	this.loginNameField = this.controller.setupWidget("login_name", {
		changeOnKeyPress : true
	}, this.loginNameModel);
	Mojo.Event.listen(this.controller.get("login_name"),
			Mojo.Event.propertyChange, function(value) {
				if (value.value.trim() != "") {
					this.btnOKModel.disabled = false;
				} else {
					this.btnOKModel.disabled = true;
				}
				this.controller.modelChanged(this.btnOKModel);
			}.bind(this));

	// password field
	this.passwordField = this.controller.setupWidget("login_password", {}, this.passwordModel);

	// OK button
	this.controller.setupWidget("login_btnOK", {}, this.btnOKModel);
	Mojo.Event.listen(this.controller.get("login_btnOK"), Mojo.Event.tap,
			function() {
				authn.spreadsheetLogin(this.loginNameModel.value, this.passwordModel.value);
			}.bind(this));

	// Cancel button
	this.controller.setupWidget("login_btnCancel", {}, this.btnCancelModel);
	Mojo.Event.listen(this.controller.get("login_btnCancel"), Mojo.Event.tap,
			function() {
				Mojo.Log.info("Cancel pressed");
			}.bind(this));
};

LoginAssistant.prototype.loginFailed = function(message) {
	$("login_failed").style.display = "inline";
	$("login_failed").innerHTML = message;
};

LoginAssistant.prototype.loginSucceeded = function(token) {
	depot.saveAuthToken(token);
};

LoginAssistant.prototype.loginFailedCaptcha = function(url, captchaToken, captchaUrl) {
	Mojo.Log.info("captcha required: " + captchaUrl)
};


LoginAssistant.prototype.activate = function(event) {
	/*
	 * put in event handlers here that should only be in effect when this scene
	 * is active. For example, key handlers that are observing the document
	 */
};

LoginAssistant.prototype.deactivate = function(event) {
	/*
	 * remove any event handlers you added in activate and do any other cleanup
	 * that should happen before this scene is popped or another scene is pushed
	 * on top
	 */
};

LoginAssistant.prototype.cleanup = function(event) {
	/*
	 * this function should do any cleanup needed before the scene is destroyed
	 * as a result of being popped off the scene stack
	 */
};
